home *** CD-ROM | disk | FTP | other *** search
- /*
- * install the mac mail watch driver
- * by Aaron Wohl (aw0g+@andrew.cmu.edu) jul 1990
- * Carnegie-Mellon University
- * Special Projects
- * Pittsburgh, PA 15213-3890
- * (412)-268-5032
- *
- * special thanks to Luni and Rich Brown @ Dartmouth
- *
- * Luni wrote the MacTCP emulator for macmach from which this file
- * borrows liberaly.
- *
- * Rich Brown provided the source to Dartmouth's BlitzNotify installer
- * which was a big help.
- */
-
- #include "mmc_drvr_find.h"
- #include "mmc_drvr_install.h"
- #include "mmc_os_preserve.h"
-
- pascal void _DrvrInstall(void) = 0xa03d;
-
- /* FUNCTION DrvrInstall(drvrHandle:Handle; refNum: INTEGER): OSErr; */
- short DrvrInstall(Handle drvrHandle, short dRef);
- short DrvrInstall(Handle drvrHandle, short dRef)
- {
- asm {
- move.w dRef,d0
- move.l drvrHandle,a0
- #ifdef RUBBISH
- /*
- * the tech note says it wants pointer not a handle
- * but it seems to be way wrong.
- */
- move.l (a0),a0
- #endif
- }
- _DrvrInstall();
- }
-
- static long find_or_install(int *refnum);
- static long find_or_install(int *refnum)
- {
- int found_ref;
- short free_ref;
- short err;
- Handle drvr;
- DCtlHandle dCtl;
-
- found_ref = mmc_drvr_find(MMC_name,&free_ref);
- if(found_ref!=0) {
- *refnum=found_ref; /*found it already open*/
- return 0; /*no error*/
- }
-
- /*
- * The resource name is .RawMailCheck.
- * The name inside the driver is .MailCheck
- * Having them be different seems to help OpenDriver below
- * pick the one DrvrInstall made up
- */
- if((drvr = GetNamedResource('DRVR',MMC_driver_resource))==0)
- return -192; /*resource not found*/
-
- HLock(drvr); /*tech note says to do this*/
- if((err = DrvrInstall(drvr,free_ref))!=0)
- return err; /*oops, this leaves driver in sys heap
- * in our case CloseResFile will nuke it
- */
- /*
- * Drvr install doesn't do anything except fill in dCtlRefNum
- * so follow up and copy over the drivers info
- */
- dCtl = GetDCtlEntry(free_ref);
- (*dCtl)->dCtlDriver = (Ptr) drvr; /*use handle, teche not is wrong*/
- (*dCtl)->dCtlStorage = (Handle) 0L;
- (*dCtl)->dCtlDelay = *(short *)(*(char **)drvr + 2);
- (*dCtl)->dCtlEMask = *(short *)(*(char **)drvr + 4);
- (*dCtl)->dCtlFlags |= **(short **)drvr;
- DetachResource(drvr); /*leave it around when CloseResFile happens*/
- return err;
- }
-
- /*
- * install the mac mail check driver
- */
- short mmc_drvr_find_or_install(short *refnum)
- {
- return OSP_protected_call(OSP_sys,find_or_install,refnum);
- }
-
-
-